import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Switch } from 'antd';

class Btn extends Component {
    render() {
        return (
            <Switch defaultChecked onChange={this.props.btnChange} />
        );
    }
}
function mapDispatchToProps(dispatch) {
    return {
        btnChange: (v) => {
            console.log(v);
            dispatch({type:v ? 'switchBtnY' : 'switchBtnN'})
        }
    };
}

//封装传递state和dispatch(只执行派发不要高阶函数)
var BtnDispatch = connect('',mapDispatchToProps)(Btn);

export default BtnDispatch;
